﻿using System;

namespace RbacLib.Models
{
    [Serializable]
    public class BaseSearch
    {
        public bool? IsActive { get; set; }
        public string SortType { get; set; }
        public string Sort { get; set; }
        public bool IsSort { get { return !string.IsNullOrEmpty(Sort); } }
        public bool? EqPk { get; set; }
        public int? ProjectId { get; set; }

        public NHibernate.Criterion.Order Order
        {
            get
            {
                var isDecs = (!string.IsNullOrEmpty(SortType) &&
                              SortType.ToLower() == "desc");

                return isDecs ? NHibernate.Criterion.Order.Desc(Sort) : NHibernate.Criterion.Order.Asc(Sort);
            }
        }
    }
}
